package starter;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

import game.classes.gameField.gameArea;
import game.classes.gameField.gameBlock;
import game.classes.gameField.gameTile;
import game.enums.BlockID;
import game.enums.FloorID;
import game.enums.MaterialID;

public class test {

	final static int MAXX = 16;
	final static int MAXY = 8;
	static gameArea myArea;
	static gameArea loadedArea;

	public static void main(String[] args) {
		myArea = new gameArea(MAXX, MAXY);
		/*for (int i = 0; i < MAXX; i++) {
			for (int j = 0; j < MAXY; j++) {
				if ((i * j) % 2 == 0) {
					myArea.setTileAtPos(i, j, FloorID.DIRT);
				} else {
					myArea.setTileAtPos(i, j, FloorID.GRASS);
				}
				if (i == 2 && j == 2) {
					myArea.setBlockAtPos(i, j, BlockID.BLOCK, MaterialID.DIRT);
				} else {
					myArea.setBlockAtPos(i, j, BlockID.NONE);
				}
			}
		}*/
		
		for (int i = 0; i < MAXX; i++) {
			for (int j = 0; j < MAXY; j++) {
				if (i==MAXX-1||i==0||j==0||j==MAXY-1||(i==4 && (j>1&&j<6)||(j==2&&(i==2||i==3||i==5||i==6)))||((j==2&&(i==9||i==13))||(j==3&&(i==13||i==9)||(j==4&&(i==10||i==12))))||(i==11&&j==5))
					myArea.setTileAtPos(i, j, FloorID.DIRT);
				else
					myArea.setTileAtPos(i, j, FloorID.GRASS);
				if (i == 2 && j == 2) {
					myArea.setBlockAtPos(i, j, BlockID.BLOCK, MaterialID.DIRT);
				} else {
					myArea.setBlockAtPos(i, j, BlockID.NONE);
				}
			}
		}
		myArea.setTileAtPos(0,0,FloorID.SAND);
		myArea.setTileAtPos(1,0,FloorID.STONE);
		myArea.setTileAtPos(2,0,FloorID.ICE);
		myArea.setTileAtPos(3,0,FloorID.LAVA);
		myArea.setTileAtPos(4,0,FloorID.WATER);
		myArea.setTileAtPos(5,0,FloorID.MARBLE);
		myArea.setTileAtPos(6,0,FloorID.QUICKSAND);
		myArea.setTileAtPos(7,0,FloorID.SWAMP);
		myArea.setTileAtPos(0,1,FloorID.GLASS);

	    try
	    {
	       FileOutputStream fileOut = new FileOutputStream("resource/level/testlevel.map");
	       ObjectOutputStream out = new ObjectOutputStream(fileOut);
	       out.writeObject(myArea);
	       out.close();
	       fileOut.close();
	    }catch(IOException i)
	    {
	        i.printStackTrace();
	    }
	    
	}

}
